package List;

import java.util.Iterator;

public class Demo {

	public static void main(String[] args) {
		LinkedList l = new LinkedList();
		l.add(1);
		//System.out.println(l.get(0));
		System.out.println(l.toString());
		l.add(2);
		System.out.println(l.toString());
		l.add(5);
		System.out.println(l.toString());
		l.addLast(8);
		System.out.println(l.toString());
		l.addFirst(3);
		System.out.println(l.toString());
		
		
		System.out.println(l.size());

		l.add(2, 9);
		System.out.println(l.toString());

		l.remove();
		System.out.println(l.toString());
		
		System.out.println(l.removeFirst());
		System.out.println(l.toString());
		
		//System.out.println(l.removeLast());
		//System.out.println(l.toString());
		

		System.out.println(l.remove(2));
		System.out.println(l.toString());
		
		l.addLast(2);
		
		System.out.println(l.toString());
		
		Iterator<?> iter = l.iterator();
		while(iter.hasNext()){
			System.out.println(iter.next());
		}
		iter.remove();
		System.out.println(l.toString());
		
		Iterator<?> diter = l.descendingIterator();
		while(diter.hasNext()){
			System.out.println(diter.next());
		}
		diter.remove();
		
		System.out.println(l.toString());
		

		
	}
}
